package com.kienbk1910.common;

import java.io.File;
import java.net.ContentHandler;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

import com.kienbk1910.productmanager.provider.DBHelper;
import com.kienbk1910.productmanager.provider.ProductProvider;

public class Commom {
	public static final String PRODUCT ="product";
	public static int NEW=1;
	public static int EDIT=0;
	public static  String MODE ="mode";
	public static String intToStringWithplot (int a){
		int b=a/1000;
		if(b == 0)
			return String.valueOf(a);
		
		return intToStringWithplot(b)+","+String.format("%03d",a%1000);
		
	}
	public static boolean checkBarCode(String barcode,Context context){
		String URL = ProductProvider.URL;
		Uri friends = Uri.parse(URL);

		Cursor cursor =context.getContentResolver().query(friends, null,
				DBHelper.BAR_CODE+" LIKE '" +barcode + "'", null,
				"name");
		if(cursor.moveToFirst()){
			return true;
		}
		return false;
	}
	public static void deleteFile(String pathName){
		if(pathName == null)
			return;
		File file = new File(pathName);
		if (file.exists()) {
			boolean deleted = file.delete();
		}
		
	}
}
